<?php

namespace app\admin\validate;

use think\Validate;

class Goods extends Validate
{
    //验证规则
    protected $rule = [
        'id' => 'require',
        'goods_name|商品名称' => 'require|max:10|token|unique:goods',
        'goods_price|商品价格' => 'require',
        'goods_number|商品数量' => 'require',
        'goods_desc|商品简介' => 'require',
    ];

    //验证场景  添加场景、修改场景、删除场景
    protected $scene = [
        'add' => ['goods_name', 'goods_price', 'goods_number', 'goods_desc'],//  添加场景
        'edit' => ['id', 'goods_name', 'goods_price', 'goods_number', 'goods_desc'], //修改场景
    ];
}